package com.orchard.orchardfarmmanagementsystem.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;

import javax.persistence.*;
import java.security.Timestamp;
import java.time.LocalDateTime;

@Entity
@Table(name = "usage_records")
public class UsageRecords {

    @Id
    @TableId(type = IdType.AUTO)
    private Long id;

    @ManyToOne
    @JoinColumn(name = "material_id", nullable = false)
    private Materials material;

    @Column(name = "user_id") // 如果有用户表，则可以改为 @ManyToOne 并关联用户表
    private Integer userId;

    @Column(name = "orchard_id") // 如果有果园表，则可以改为 @ManyToOne 并关联果园表
    private Integer orchardId;

    @Column(name = "plot_id") // 如果有地块表，则可以改为 @ManyToOne 并关联地块表
    private Integer plotId;

    @Column(nullable = false)
    private Integer usedQuantity;

    @Column(name = "borrow_date", updatable = false)
    private LocalDateTime borrowDate;

    @Column(name = "return_date")
    private LocalDateTime returnDate;

    @Column(columnDefinition = "TEXT")
    private String remarks;

    @Column(name = "created_at", updatable = false)
    private LocalDateTime createdAt;

    // Getters and Setters
}